import request from '_utils/request'
// 请求分类接口
const fetchCates =(params={})=>request.get('/shop/goods/category/all',{params})
// 获取首页轮播
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })
// 获取下拉商品
const fetchListItems = (params = {}) => request.post('/shop/goods/list/v2',  params )
// 获取商品详情
const fetchItemDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
 // 用户注册
 const doRegister = (params = {}) => request.post('user/username/register',  params )
  
 // 用户登录
 const doLogin =(params={})=>request.post('/user/username/login', params)
 
 // 加入购物车
 const addCart =(params={})=>request.post('/shopping-cart/add', params)
 // 获取购物车数据
 const fetchCartInfo =(params={})=>request.get('/shopping-cart/info',{params})
 // 修改购物车商品购买数量
 const setItemNum = (params = {}) =>request.post('/shopping-cart/modifyNumber',params)
 // 删除购物车商品
 const delItem = (params = {}) =>request.post('/shopping-cart/remove',params)
 // 修改购物车商品选中状态
 const itemStateChange =(params = {}) =>request.post('/shopping-cart/select',params)
 // 创建订单
 const createOrder = (params = {}) =>request.post('/order/create',params)
 // 新增收货地址
 const addContact = (params = {}) =>request.post('/user/shipping-address/add',params)
 
 // 获取收货地址列表
 const fetchAddress = (params = {}) =>request.post('/user/shipping-address/list/v2',params)
 // 获取收货地址详情
 const getContactInfo =(params={})=>request.get('/user/shipping-address/default/v2',{params})
 
 // 修改联系人 /user/shipping-address/update
const updateAddress = (params = {}) => request.post('/user/shipping-address/update', params)
// 删除联系人 /user/shipping-address/delete
const delContact = (params = {}) => request.post('/user/shipping-address/delete', params)

 export{
  fetchCates,
  fetchHomeBanner,
  fetchListItems,
  fetchItemDetail,
  doRegister,
  doLogin,
  addCart,
  fetchCartInfo,
  setItemNum,
  delItem,
  itemStateChange,
  createOrder,
  addContact,
  fetchAddress,
  getContactInfo,
  updateAddress,
  delContact
}